State.h
Language: C++
Last Modified: 2022-09-10 5:29:27 PM UTC
File Size: 1818 bytes
Last Modified: 2022-09-10 5:29:27 PM UTC
File Size: 1818 bytes
http://www.penguinstew.ca/example/CodeFormater/State.h
#pragma once
#include <string>
#include <vector>
#include <regex>
#include <libxml/tree.h>
#include "TypeIdPair.h"
enum class StateTypes
{
IncludeStart,
IncludeStartWord,
ExcludeStart,
NoColour,
};
class State
{
//Id of this state
int id;
//type of the state
StateTypes type;
//style name of the colour to display
std::string colour;
//True to test for nested states
bool allowNested;
//True to test for escape characters
bool useEscape;
//Starting characters
std::string startSequence;
//Ending characters
std::string endSequence;
//The regular expression to use when testing word boundaries
std::string regExText;
std::regex regEx;
//Used with sym type to indicate words to test for
std::vector<std::string> words;
std::vector<TypeIdPair> startIds;
bool endAfterWord;
bool endAfterLine;
public:
static const std::string STATE_PATTERN_LINE;
static const std::string STATE_PATTERN_WORD;
State();
State(xmlNodePtr xmlNode);
int GetId();
StateTypes GetType();
std::string GetColour();
bool GetAllowNested();
bool GetUseEscapee();
std::string GetStartSequence();
std::string GetEndSequence();
std::regex GetRegEx();
std::vector<std::string> GetWords();
std::vector<TypeIdPair> GetStartIds();
bool IsEndAfterWord();
bool IsEndAfterLine();
bool IsStart(std::string line, int pos, TypeIdPair typeId, std::string escapse);
bool IsEnd(std::string line, int pos, TypeIdPair typeId, std::string escapse);
int PrintStart(std::stringstream& lineStream,std::string line, int pos);
int PrintEnd(std::stringstream& lineStream);
void PrintRestart(std::stringstream& lineStream);
void PrintClose(std::stringstream& lineStream);
std::string FindStateWord(std::string line, int pos);
std::string ToString();
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68